// import com.alibaba.druid.sql.ast.SQLExpr_ptr;
// import com.alibaba.druid.sql.ast.SQLName_ptr;
// import com.alibaba.druid.sql.ast.SQLObject;
// import com.alibaba.druid.sql.ast.SQLStatementImpl;
// import com.alibaba.druid.sql.ast.expr.SQLPropertyExpr;
// import com.alibaba.druid.sql.visitor.SQLASTVisitor;

// import java.util.ArrayList;
// import java.util.List;

#include "SQLCreateSequenceStatement.h"
#include "../../visitor/SQLASTVisitor.h"
#include "../../../utils/instanceof.h"
#include "../expr/SQLPropertyExpr.h"

SQLCreateSequenceStatement::SQLCreateSequenceStatement()
{
}

// @Override
void SQLCreateSequenceStatement::accept0(SQLASTVisitor_ptr visitor)
{
  if (visitor->visit(SharedObject(SQLCreateSequenceStatement)))
  {
    acceptChild(visitor, name);
    acceptChild(visitor, startWith);
    acceptChild(visitor, incrementBy);
    acceptChild(visitor, minValue);
    acceptChild(visitor, maxValue);
  }
  visitor->endVisit(SharedObject(SQLCreateSequenceStatement));
}

// @Override
SQLObject_list_ptr SQLCreateSequenceStatement::getChildren()
{
  SQLObject_list_ptr children = std::make_shared<std::list<SQLObject_ptr>>();
  if (name != nullptr)
  {
    children->push_back(name);
  }
  if (startWith != nullptr)
  {
    children->push_back(startWith);
  }
  if (incrementBy != nullptr)
  {
    children->push_back(incrementBy);
  }
  if (minValue != nullptr)
  {
    children->push_back(minValue);
  }
  if (maxValue != nullptr)
  {
    children->push_back(maxValue);
  }
  return children;
}

SQLName_ptr SQLCreateSequenceStatement::getName()
{
  return name;
}

void SQLCreateSequenceStatement::setName(SQLName_ptr name)
{
  this->name = name;
}

SQLExpr_ptr SQLCreateSequenceStatement::getStartWith()
{
  return startWith;
}

void SQLCreateSequenceStatement::setStartWith(SQLExpr_ptr startWith)
{
  this->startWith = startWith;
}

SQLExpr_ptr SQLCreateSequenceStatement::getIncrementBy()
{
  return incrementBy;
}

void SQLCreateSequenceStatement::setIncrementBy(SQLExpr_ptr incrementBy)
{
  this->incrementBy = incrementBy;
}

SQLExpr_ptr SQLCreateSequenceStatement::getMaxValue()
{
  return maxValue;
}

void SQLCreateSequenceStatement::setMaxValue(SQLExpr_ptr maxValue)
{
  this->maxValue = maxValue;
}

BOOL_ptr SQLCreateSequenceStatement::getCycle()
{
  return cycle;
}

void SQLCreateSequenceStatement::setCycle(BOOL_ptr cycle)
{
  this->cycle = cycle;
}

BOOL_ptr SQLCreateSequenceStatement::getCache()
{
  return cache;
}

void SQLCreateSequenceStatement::setCache(BOOL_ptr cache)
{
  this->cache = cache;
}

BOOL_ptr SQLCreateSequenceStatement::getOrder()
{
  return order;
}

void SQLCreateSequenceStatement::setOrder(BOOL_ptr order)
{
  this->order = order;
}

SQLExpr_ptr SQLCreateSequenceStatement::getMinValue()
{
  return minValue;
}

void SQLCreateSequenceStatement::setMinValue(SQLExpr_ptr minValue)
{
  this->minValue = minValue;
}

BOOL_ptr SQLCreateSequenceStatement::isNoMaxValue()
{
  return noMaxValue;
}

void SQLCreateSequenceStatement::setNoMaxValue(BOOL_ptr noMaxValue)
{
  this->noMaxValue = noMaxValue;
}

BOOL_ptr SQLCreateSequenceStatement::isNoMinValue()
{
  return noMinValue;
}

void SQLCreateSequenceStatement::setNoMinValue(BOOL_ptr noMinValue)
{
  this->noMinValue = noMinValue;
}

string_ptr SQLCreateSequenceStatement::getSchema()
{
  SQLName_ptr name = getName();
  if (name == nullptr)
  {
    return nullptr;
  }

  if (instanceof <SQLName, SQLPropertyExpr>(name))
  {
    return (std::dynamic_pointer_cast<SQLPropertyExpr>(name))->getOwnernName();
  }

  return nullptr;
}

SQLExpr_ptr SQLCreateSequenceStatement::getCacheValue()
{
  return cacheValue;
}

void SQLCreateSequenceStatement::setCacheValue(SQLExpr_ptr cacheValue)
{
  if (cacheValue != nullptr)
  {
    cacheValue->setParent(SharedObject(SQLCreateSequenceStatement));
  }
  this->cacheValue = cacheValue;
}

BOOL_ptr SQLCreateSequenceStatement::isSimple()
{
  return simple;
}

void SQLCreateSequenceStatement::setSimple(BOOL_ptr simple)
{
  this->simple = simple;
}

BOOL_ptr SQLCreateSequenceStatement::isGroup()
{
  return group;
}

void SQLCreateSequenceStatement::setGroup(BOOL_ptr group)
{
  this->group = group;
}

SQLExpr_ptr SQLCreateSequenceStatement::getUnitCount()
{
  return unitCount;
}

void SQLCreateSequenceStatement::setUnitCount(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLCreateSequenceStatement));
  }
  this->unitCount = x;
}

SQLExpr_ptr SQLCreateSequenceStatement::getUnitIndex()
{
  return unitIndex;
}

void SQLCreateSequenceStatement::setUnitIndex(SQLExpr_ptr x)
{
  if (x != nullptr)
  {
    x->setParent(SharedObject(SQLCreateSequenceStatement));
  }
  this->unitIndex = x;
}

BOOL_ptr SQLCreateSequenceStatement::isTime()
{
  return time;
}

void SQLCreateSequenceStatement::setTime(BOOL_ptr time)
{
  this->time = time;
}

BOOL_ptr SQLCreateSequenceStatement::getWithCache()
{
  return withCache;
}

void SQLCreateSequenceStatement::setWithCache(BOOL_ptr withCache)
{
  this->withCache = withCache;
}

SQLExpr_ptr SQLCreateSequenceStatement::getStep()
{
  return step;
}

void SQLCreateSequenceStatement::setStep(SQLExpr_ptr step)
{
  if (step != nullptr)
  {
    step->setParent(SharedObject(SQLCreateSequenceStatement));
  }
  this->step = step;
}

// @Override
SQLDDLStatement::DDLObjectType SQLCreateSequenceStatement::getDDLObjectType()
{
  return SQLDDLStatement::DDLObjectType::SEQUENCE;
}
